package com.traffic.fuwu.service.impl;

import com.traffic.fuwu.dao.SftpMapper;
import com.traffic.fuwu.mybatis.pojo.Sftp;
import com.traffic.fuwu.mybatis.pojo.SftpExample;
import com.traffic.fuwu.service.SftpService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by pikewei on 2017/2/7.
 */
@Service
public class SftpServiceImpl implements SftpService {
    @Autowired
    private SftpMapper sftpMapper;

    @Override
    public Sftp getById(int sftpId) {
        SftpExample example = new SftpExample();
        example.or().andIdEqualTo(sftpId);
        try {
            List<Sftp> list = sftpMapper.selectByExample(example);
            if (list != null && list.size() != 0) {
                Sftp sftp = list.get(0);
                return sftp;
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }

    @Override
    public Sftp getByAccount(String account) {
        SftpExample example = new SftpExample();
        example.or().andAccountEqualTo(account);
        try {
            List<Sftp> list = sftpMapper.selectByExample(example);
            if(list != null && list.size() != 0){
                Sftp sftp = list.get(0);
                return sftp;
            }
        }catch (Exception e){
            e.printStackTrace();
        }

        return null;
    }
}
